<?php
    /**
    * Product Categories - Save
    * @author tunv
    * @since Apr 10, 2012
    * 
    * Change logs
    * 
    */

    if (!defined('EXPONENT')) exit('');

    $cat = null;
    $id = 0;
    if(isset($_REQUEST['id']))
    {
        $id = intval($_REQUEST['id']); 
    }
    $survey = $db->selectObject('surveymodule_table_survey',"id=".$id);
    if (exponent_permissions_check(array('administrate','configure'),$loc)) {
        $survey = surveymodule_cat::survey_update($_POST,$survey);
        $survey->location_data = serialize($loc);
        //Cho nay de insert field rank
        $survey->rank = $db->max('surveymodule_table_survey', 'rank', 'location_data', "location_data='".serialize($loc)."'");
        if ($survey->rank == null) {
            $survey->rank = 0;
        } else {
            $survey->rank += 1;
        }
        if (isset($survey->id)) {
            $db->updateObject($survey,'surveymodule_table_survey');
        } else {
            $db->insertObject($survey,'surveymodule_table_survey');
        }

        // clear category cache
        //exponent_sessions_set("__PDoremiShop_CategorySeoNameBuild_Cats", null);
        exponent_flow_redirect();
    } else {
        echo SITE_404_HTML;
    }

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">

<html>
<head>
  <meta name="generator" content=
  "HTML Tidy for Windows (vers 14 February 2006), see www.w3.org">

  <title></title>
</head>

<body>
</body>
</html>
